<template>
  <div class='search'>
    <f-form ref='form' :action='api.bod' :form-key='this.formItem.orderDetailsId' handler-name='calculateUpdateHandler'>
      <f-form-item label='购方资信' type='radio' name='customBondType' :disabled='true' dataType='number' :data='api.busOrder.customBondType' :value.sync='formItem.customBondType' />
      <f-form-item label='公司垫付' type='radio' name='supplierBondType' :disable='true' :disabled='true' dataType='number' :data='api.busOrder.supplierBondType' :value.sync='formItem.supplierBondType' />

      <f-form-item label='数量' type='number' data-type='number' :disabled='disabled' :min='-5000' name='saleNum' :value='formItem.saleNum' />
      <f-form-item label='销售价' type='number' data-type='number' :disabled='disabled' :precision='4' name='salePrice' :value='formItem.salePrice' />
      <f-form-item label='成本价' type='number' :precision='4'  data-type='number' name='costPrice' :value='formItem.costPrice' />
      <f-form-item label='结算价' type='number' :precision='4'  data-type='number' name='settlePrice' :value='formItem.settlePrice' />
      <!--      <f-form-item label="折扣价" type="number" data-type="number" :precision="4" name="discountPrice" :value="formItem.discountPrice"/>-->
      <a-divider orientation='left'>供货方费率</a-divider>
      <f-form-item label='税金费率' type='number' :precision='4' data-type='number' name='supplierTaxRate' :value='formItem.supplierTaxRate' />
      <f-form-item label='结算费率' type='number' :precision='4' data-type='number' name='supplierSettleRate' :value='formItem.supplierSettleRate' />
      <f-form-item label='返款公式' name='refundFormulaId' type='select' :value='formItem.refundFormulaId' :data='api.formula.list' valueKey='formulaId' label-key='formulaContent' :params='params1' />
      <f-form-item label='高开税金公式' name='highTaxRateFormulaId' type='select' :value='formItem.highTaxRateFormulaId' :data='api.formula.list' valueKey='formulaId' label-key='formulaContent' :params='params2' />

      <a-divider orientation='left'>市场费率</a-divider>
      <f-form-item label='税金费率' type='number' :precision='4' data-type='number' name='customTaxRate' :value='formItem.customTaxRate' />
      <f-form-item label='结算费率' type='number' :precision='4' data-type='number' name='customSettleRate' :value='formItem.customSettleRate' />
      <f-form-item label='高开税金费率' type='number'  :precision='4' data-type='number' name='customSettleGapUpTaxRate' :value='formItem.customSettleGapUpTaxRate' />
      <f-form-item label='结算公式' name='settleFormulaId' type='select' :value='formItem.settleFormulaId' :data='api.formula.list' valueKey='formulaId' label-key='formulaContent' :params='params3' />
      <f-form-item label='结算公式2' name='settleFormulaId2' type='select' :value='formItem.settleFormulaId2' :data='api.formula.list' valueKey='formulaId' label-key='formulaContent' :params='params3' v-show="formItem.settleType==1"/>
      <f-form-item label='结算公式3' name='settleFormulaId3' type='select' :value='formItem.settleFormulaId3' :data='api.formula.list' valueKey='formulaId' label-key='formulaContent' :params='params3' v-show="formItem.settleType==1"/>
      <f-form-item label='利润公式' name='profitAmountFormulaId' type='select' :value='formItem.profitAmountFormulaId' :data='api.formula.list' valueKey='formulaId' label-key='formulaContent' :params='params4' />
    </f-form>
  </div>
</template>
<script>
import api from "../js/api"

export default {
  name: "orderCalculateTab1",
  props: {},
  data() {
    return {
      refs: this.$refs,
      loadDept: false,
      supplieBtn: true,
      amountTitle: "回款日期",
      api: Object.assign(api, this.api),
      isAdd: true,//是否是添加模式
      loaded: false,//是否加载完成
      formItem: this.getFormItem(),
      disabled:false,
      params1: {
        formulaType: 1
      },
      params2: {
        formulaType: 4
      },
      params3: {
        formulaType: 3
      },
      params4: {
        formulaType: 2
      }
    }
  },
  methods: {
    getFormItem() {
      return {
        orderId: "",
        orderNo: "",
        delivery: "",
        saleManName: "",
        customName: "",
        invoiceSendType: 0,
        reputation: "",
        reputationAmount: "",
        bankId: "",
        settleType:0,
        customBondType: 0,
        supplierBondType: 0,
        customId: "",
        billsType: "",
        remark: ""
      }
    },
    //表单赋值
    setData(data) {
      this.$refs.form.resetFields()
      this.formItem = this.getFormItem()
      if (data && data.orderDetailsId) {
        if(data.orderState==2){
          this.disabled=true;
        }
        this.http.get(this, {
          url: this.api.bod.get,
          params: {
            orderDetailsId: data.orderDetailsId,
            handlerName: "calCulateTab1GetHandler"
          },
          success: function(me, data) {
            me.formItem = data
          }
        })

      }
    },
    //提交表单
    handleSubmit(callback) {
      this.$refs.form.submit({
        orderId: this.formItem.orderId,
        drugsId: this.formItem.drugsId,
        drugsLotId: this.formItem.drugsLotId,
        optType:1,
        customId: this.formItem.customId,
        saleType: this.formItem.saleType
      }, callback)
    }
  },
  mounted() {

  },
  created() {
  },
  components: {}
}
</script>

<style scoped lang='less' rel='stylesheet/less'>

</style>
